<?php
/**
 * Main entry of the webapp
 * Displayed the main page wanted
 * If it is not an ajax request, add all the internals pages
 */
header('Content-Type: text/html; charset=UTF-8');

require_once("include/setup.php");

$internal_pages = array(
	'dialog.connect_mikubook.php', 'video_detail.php', 'tag_videolist.php', 'tag.php', 'top20.php', 
	'search_words.php', 'video_newest.php'
);
$firstpage = $_REQUEST['page'];
if (empty($firstpage)) {
	$firstpage = 'about.php';
}

$headers = apache_request_headers();
if (!empty($headers['X-Requested-With']) && $headers['X-Requested-With'] == 'XMLHttpRequest') {
	includeview("templates/pages/$firstpage");
}
else {
	includeview("templates/include/header.php", "title", "MikuClip");
	includeview("templates/pages/$firstpage");
	foreach ($internal_pages as $p) {
		includeview("templates/pages/$p");
	}
	includeview("templates/include/footer.php");
}